﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using WpfApp2;

namespace LocalServer.Utils
{
    public class LedUtil
    {
        public static String textScreenName = "Led001";
        public static String textProgramId = "001";
        public static String textProgramName = "program001";
        public static String tBoxRefreshText = "";
        //public static String textIp = "192.168.1.102";

        public static String createStaticTextArea(int id, int left, int top, int width, int height, String text, int siderType, int fontSize = 20)
        {
            StaticTextArea textArea = new StaticTextArea();
            textArea.id = id;
            textArea.type = 200;//静态区域和字幕区域属性有通用的地方.但大部分
            textArea.left = left;
            textArea.top = top;
            textArea.width = width;
            textArea.height = height;

            textArea.background = "#000000";
            textArea.fontColor = "#ff0000";
            textArea.fontFamily = "宋体";//当前只支持默认字体.字体需要设备端有对应字库才能支持
            textArea.fontSize = fontSize;
            textArea.text = text;
            textArea.zIndex = 1;
            textArea.siderType = siderType;
            string strTextjson = JsonExtension.ToJSON(textArea);//对象转为Json

            return strTextjson;
        }
        public static void refreshTextArea(RefreshData refreshData,string ledIp)
        {
            List<RefreshData> list = new List<RefreshData>();
            list.Add(refreshData);

            string strRefreshData = JsonExtension.ToJSON(list);//对象转为Json

            byte[] byRefreshData = System.Text.Encoding.UTF8.GetBytes(strRefreshData);


            byte[] byIp = System.Text.Encoding.UTF8.GetBytes(ledIp);
            int nRet = ListenDll.LV_RefreshFixedArea(byIp, byRefreshData);
            Console.WriteLine(nRet);
        }
    }
}
